package com.fz.us.oa.core.entity.com;

import com.fz.us.admin.company.entity.*;

import com.fz.us.admin.dict.entity.DictItem;
import com.fz.us.oa.core.entity.common.FileManage;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * Created by ZhuChunXiao on 2017/1/12.
 * 发文登记表
 */
@Entity
@Table(name="ec_dispatch")
public class Dispatch extends BaseFlowEntity {


    private static final long serialVersionUID = -1491689912096011438L;
    /**
     * 发文类别
     */
    private DictItem type;
    /**
     * 发文标题
     */
    private String title;
    /**
     * 文件编号
     */
    private String fileNo;
    /**
     * 发文时间
     */
    private Date time;
    /**
     * 发文对象
     *  1全体员工  2部门 3个人
     */
    private String object;
    /**
     * 通知部门
     */
    private List<Department> noticeDepartment;

    /**
     * 通知个人
     */
    private List<User> noticeUsers;
    /**
     * 是否具备有效期
     */
    private boolean hasValid;
    /**
     * 有效期
     */
    private Date validDate;
    /**
     * 相关附件
     */
    private List<FileManage> file;

    /**
     * 是否需要会签
     */
    private boolean mulExam;

    /**
     * 会签人员
     */
    private List<User> examUsers;

    /**
     * 是否需要中心领导审核
     */
    private boolean leaderExam;

    /**
     * 中心审核对象
     */
    private List<Power> examObject;

    /**
     * 是否失效
     */
    private boolean invalid;

    /**
     * 发文对象的职责id
     */
    private String dutyIds;
    /**
     * 会签人员职责id
     * @return
     */
    private String dutyChooseIds;

    /**
     * 中心审核对象职责id
     * @return
     */
    private String dutyLeadIds;


    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getFileNo() {
        return fileNo;
    }

    public void setFileNo(String fileNo) {
        this.fileNo = fileNo;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getObject() {
        return object;
    }

    public void setObject(String object) {
        this.object = object;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_dispatch_noticeDepartment", joinColumns = @JoinColumn(name = "id"), inverseJoinColumns = @JoinColumn(name = "noticeDepartmentId"))
    public List<Department> getNoticeDepartment() {
        return noticeDepartment;
    }

    public void setNoticeDepartment(List<Department> noticeDepartment) {
        this.noticeDepartment = noticeDepartment;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_dispatch_noticeUsers", joinColumns = @JoinColumn(name = "id"), inverseJoinColumns = @JoinColumn(name = "noticeUsersId"))
    public List<User> getNoticeUsers() {
        return noticeUsers;
    }

    public void setNoticeUsers(List<User> noticeUsers) {
        this.noticeUsers = noticeUsers;
    }

    @Column(columnDefinition = "tinyint(1) default 0")
    public boolean isHasValid() {
        return hasValid;
    }

    public void setHasValid(boolean hasValid) {
        this.hasValid = hasValid;
    }

    public Date getValidDate() {
        return validDate;
    }

    public void setValidDate(Date validDate) {
        this.validDate = validDate;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_dispatch_file", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="fileId"))
    public List<FileManage> getFile() {
        return file;
    }

    public void setFile(List<FileManage> file) {
        this.file = file;
    }

    @Column(columnDefinition = "tinyint(1) default 0")
    public boolean isMulExam() {
        return mulExam;
    }

    public void setMulExam(boolean mulExam) {
        this.mulExam = mulExam;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_dispatch_examUsers", joinColumns = @JoinColumn(name = "id"), inverseJoinColumns = @JoinColumn(name = "examUsersId"))
    public List<User> getExamUsers() {
        return examUsers;
    }

    public void setExamUsers(List<User> examUsers) {
        this.examUsers = examUsers;
    }

    @Column(columnDefinition = "tinyint(1) default 0")
    public boolean isLeaderExam() {
        return leaderExam;
    }

    public void setLeaderExam(boolean leaderExam) {
        this.leaderExam = leaderExam;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ec_dispatch_examObject", joinColumns = @JoinColumn(name = "id"), inverseJoinColumns = @JoinColumn(name = "examObjectId"))
    public List<Power> getExamObject() {
        return examObject;
    }

    public void setExamObject(List<Power> examObject) {
        this.examObject = examObject;
    }

    @Column(columnDefinition = "tinyint(1) default 0")
    public boolean isInvalid() {
        return invalid;
    }

    public void setInvalid(boolean invalid) {
        this.invalid = invalid;
    }

    @Type(type="text")
    public String getDutyLeadIds() {
        return dutyLeadIds;
    }

    public void setDutyLeadIds(String dutyLeadIds) {
        this.dutyLeadIds = dutyLeadIds;
    }

    @Type(type="text")
    public String getDutyIds() {
        return dutyIds;
    }

    public void setDutyIds(String dutyIds) {
        this.dutyIds = dutyIds;
    }

    @Type(type="text")
    public String getDutyChooseIds() {
        return dutyChooseIds;
    }

    public void setDutyChooseIds(String dutyChooseIds) {
        this.dutyChooseIds = dutyChooseIds;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public DictItem getType() {
        return type;
    }

    public void setType(DictItem type) {
        this.type = type;
    }
}
